package com.lcz.googleplay.fragment;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by hp on 2016/10/25.
 */

public class FragmentFactory {
    private static Map<Integer, BaseFragment> map = new HashMap<>();


    public static BaseFragment createFragment(int position) {
        BaseFragment fragment = map.get(position);
        if (fragment == null) {
            switch (position) {
                case 0:
                    fragment = new HomeFragment();//首页
                    break;
                case 1:
                    fragment = new AppFragment();//应用
                    break;
                case 2:
                    fragment = new GameFragment();//游戏
                    break;
                case 3:
                    fragment = new SubjectFragment();//专题
                    break;
                case 4:
                    fragment = new CategoryFragment();//分类
                    break;
                case 5:
                    fragment = new TopFragment();//排行
                    break;
            }
            map.put(position, fragment);
        }
        return fragment;
    }
}
